/**
 * Created by Sean Patrick Floyd (<a
 * href="mailto:sfloyd@mytoys.de">sfloyd@mytoys.de</a>) on 15.06.2010.
 */
package com.google.code.wicket.auth.component.strategy.part;

import org.apache.wicket.Component;
import org.apache.wicket.authorization.Action;

/**
 * A Strategy to determine if a component action is allowed based on runtime
 * information from the component. Designed as a substitute for
 * {@link org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(Component, Action)
 * IAuthorizationStrategy.isActionAuthorized(..)}.
 */
public interface DynamicAuthorizationStrategy {

    /**
     * A {@link DynamicAuthorizationStrategy} that always returns true.
     */
    DynamicAuthorizationStrategy ALLOW_ALL = new DynamicAuthorizationStrategy() {

        @Override
        public boolean isActionAuthorized(final Component component,
                final Action action) {
            return true;
        }
    };

    /**
     * Is the action allowed?
     * 
     * @param component
     *            the component
     * @param action
     *            the action
     * @return true if the action is allowed
     */
    boolean isActionAuthorized(Component component, Action action);

}
